package com.systemmanger.mapper;

import com.bean.WmsTGroup;
import com.bean.WmsTPermission;
import com.bean.WmsTUG;
import com.bean.WmsTUser;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * @AUTHOR(闫晨航)
 * @date2021-12-06 15:54
 */
public interface UserMapper {

    @Select("select * from wms_t_user where userIsDel='0'")
    public List<WmsTUser> getAllUsers();
    @Select("<script>select * from wms_t_user\n" +
            "        where 1=1\n" +
            "        <if test=\"userName!=null\">\n" +
            "            and userName = #{userName}\n" +
            "        </if>\n" +
            "        <if test=\"userID!=null\">\n" +
            "            and userID = #{userID}\n" +
            "        </if> and userIsDel='0'\n" +
            "</script>")
    List<WmsTUser> getUsers(Map<String, Object> map);
    @Update("update wms_t_user set userIsDel = '1' where userID=#{value}")
    public void delByUserId(String userID);
    @Select("select * from wms_t_user where userID = #{value}")
    public WmsTUser getuserByUserId(String userID);
    @Update("update wms_t_user set userName=#{userName},userAccount=#{userAccount},userPwd=#{userPwd},userNote=#{userNote},userEditTime=#{userEditTime},userType=#{userType} where userID = #{userId}")
    public void updateByUser(WmsTUser wmsTUser);
    @Select("select * from wms_t_u_g")
    public List<WmsTUG> getAllgroup();
    @Select("select * from wms_t_permission where permIsDel = '0'")
    public List<WmsTPermission> getAllPerm();
    @Select("select * FROM wms_t_permission where permID in(\n" +
            "SELECT permID from wms_t_perm_group where groupID in (\n" +
            "select uggroupID from wms_t_u_g where ugUserId=#{value}))")
    public WmsTPermission getOnePermByUid(String userID);
    @Select("select * from wms_t_permission where permID = #{value}")
    public WmsTPermission getOnePermByPid(String permId);
    @Select("select * from wms_t_group where groupID in(\n" +
            "select groupID from wms_t_perm_group where permID = #{value})")
    public WmsTGroup getOgroup(String permId);
    @Update("update wms_t_u_g set ugGroupid = #{groupId} where ugUserId = #{userId}")
    public void updateugByGroupId(@Param("groupId") String groupId,@Param("userId") String userId);
}
